package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

/**
 * @author 老杨
 * @version 1.0
 */
@Mapper
public interface ShoppingCartMapper {

    /**
     * 动态查询 购物车
     * @param shoppingCart
     * @return
     */
   List< ShoppingCart> select(ShoppingCart shoppingCart);

   @Update("update shopping_cart set number = #{number} where id = #{id}")
    void update(ShoppingCart select);

    /**
     * 插入购物车数据
     * @param shoppingCart
     */
   @Insert("insert into shopping_cart(name,image,user_id,dish_id,setmeal_id,dish_flavor,number,amount,create_time) " +
           "values (#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void insert(ShoppingCart shoppingCart);


    /**
     * 通过id 删除 购物车表
     * @param ids
     */
//   @Delete("delete from shopping_cart where id = #{id}")
    void delete(List<Long> ids);

    /**
     * 根据 用户 id 删除对应数据
     * @param uid
     */
    @Delete("delete from shopping_cart where user_id = #{uid} ")
    void delete2(Long uid);

    /**
     * 批量插入 购物车数据
     * @param shoppingCartList
     */
    void insertBatch(List<ShoppingCart> shoppingCartList);
}
